#ifndef _ALARMS_H
#define _ALARMS_H

/*****************************************************************************
 * Includes                                                                  *
 *****************************************************************************/

#include "test_configuration.h" 
#include "Tasks.h"
#include "bios.h"

/*****************************************************************************
 * Macros Definitions                                                        *
 *****************************************************************************/
/* Alarm Defines */
#define ACTIVATETASK 0
#define SETEVENT     1 
#define CALLBACK     2

/*****************************************************************************
 * Objects Definitions                                                       *
 *****************************************************************************/

typedef struct COUNTER_OBJECT
{
  unsigned int MINCYCLE; 
  unsigned int MAXALLOWEDVALUE;
  unsigned int TICKSPERBASE;
} COUNTER;

typedef struct ALARM_OBJECT
{
  COUNTER COUNT_OBJECT;
  TASK    *TASK_ALARM; 
  unsigned int CRONO;
  unsigned int cycleTicks;
  unsigned int incrementTicks;
  unsigned int startTicks;
  unsigned char ACTION;
  unsigned char A_AUTOSTART;
  unsigned char started;
} ALARM;

/*****************************************************************************
 * Global Variables                                                          *
 *****************************************************************************/ 

extern ALARM *alarmSchedule[fifoSize];
extern ALARM ALARM_A;
extern COUNTER SYSTEMTIMER;

/*****************************************************************************
 * Function Prototypes                                                          *
 *****************************************************************************/

unsigned char insertTaskByAlarm(void);
void SetRelAlarm (ALARM* AlarmID, unsigned int IncrementTicks, 
unsigned int CycleTicks);
void SetAbsAlarm(ALARM* AlarmID, unsigned int StartTicks, 
unsigned int CycleTicks);
void alarmAction(void);
void CancelAlarm (ALARM* AlarmID);

#endif